<template>
  <CommonCard title="今日销售额" :value="(numberFormat(salesToday) as string)">
    <template #default>
      <div class="compare">
        <div class="emphasis">日同比 &nbsp;{{salesGrowthLastDay}}% &nbsp;<span class="decrement"></span></div>
        <div class="emphasis">月同比 &nbsp;{{salesGrowthLastMonth}}% &nbsp;<span class="increment"></span> </div>
      </div>
    </template>
    <template #footer>
      <div>昨日销售额 <span class="emphasis">{{moneyFormat(salesLastDay)}}</span></div>
    </template>
  </CommonCard>
</template>

<script lang="ts">
export default {
  name: 'TodaySales'
};
</script>
<script lang="ts" setup>
import { computed} from 'vue'
import CommonCard from './CommonCard.vue';
import { useReportDataStore } from '@/stores/reportData'
import useFormat from '@/hooks/useFormat'
const {numberFormat, moneyFormat} = useFormat()
const reportInfoStore = useReportDataStore()

// 使用计算属性精间一下数据项
// 1. 今日销售额
// const salesToday = computed(() => {
//   return reportInfoStore.reportInfo.salesToday
// })

const salesToday = computed(() => reportInfoStore.reportInfo.salesToday)

// 2.  昨日销售额
const salesLastDay = computed(() => reportInfoStore.reportInfo.salesLastDay)
// 3. 日同比
const salesGrowthLastDay = computed(() => reportInfoStore.reportInfo.salesGrowthLastDay)

// 4. 月同比
const salesGrowthLastMonth = computed(() => reportInfoStore.reportInfo.salesGrowthLastMonth)

</script>

<style lang="scss" scoped>
.compare {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  >div {
    display: flex;
    align-items: center;
  }
}
</style>